home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Magazine / Morphos / GCC / ppc-amigaos / include / ctype.h < prev    next >
C/C++ Source or Header  |  1996-12-11  |  4KB  |  115 lines

  1. /*    $NetBSD: ctype.h,v 1.14 1994/10/26 00:55:47 cgd Exp $    */
  2.  
  3. /*
  4.  * Copyright (c) 1989 The Regents of the University of California.
  5.  * All rights reserved.
  6.  * (c) UNIX System Laboratories, Inc.
  7.  * All or some portions of this file are derived from material licensed
  8.  * to the University of California by American Telephone and Telegraph
  9.  * Co. or Unix System Laboratories, Inc. and are reproduced herein with
  10.  * the permission of UNIX System Laboratories, Inc.
  11.  *
  12.  * Redistribution and use in source and binary forms, with or without
  13.  * modification, are permitted provided that the following conditions
  14.  * are met:
  15.  * 1. Redistributions of source code must retain the above copyright
  16.  *    notice, this list of conditions and the following disclaimer.
  17.  * 2. Redistributions in binary form must reproduce the above copyright
  18.  *    notice, this list of conditions and the following disclaimer in the
  19.  *    documentation and/or other materials provided with the distribution.
  20.  * 3. All advertising materials mentioning features or use of this software
  21.  *    must display the following acknowledgement:
  22.  *    This product includes software developed by the University of
  23.  *    California, Berkeley and its contributors.
  24.  * 4. Neither the name of the University nor the names of its contributors
  25.  *    may be used to endorse or promote products derived from this software
  26.  *    without specific prior written permission.
  27.  *
  28.  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  29.  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  30.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  31.  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  32.  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  33.  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  34.  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  35.  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  36.  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  37.  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  38.  * SUCH DAMAGE.
  39.  *
  40.  *    @(#)ctype.h    5.3 (Berkeley) 4/3/91
  41.  */
  42.  
  43. #ifndef _CTYPE_H_
  44. #define _CTYPE_H_
  45. #include <sys/cdefs.h>
  46.  
  47. #define    _U    0x01
  48. #define    _L    0x02
  49. #define    _N    0x04
  50. #define    _S    0x08
  51. #define    _P    0x10
  52. #define    _C    0x20
  53. #define    _X    0x40
  54. #define    _B    0x80
  55.  
  56. #ifdef _KERNEL
  57. extern const char _ctype_[];
  58. #else
  59. extern const char    *_ctype_;
  60. #endif
  61.  
  62. __BEGIN_DECLS
  63. extern int    isalnum __P ((int));
  64. extern int    isalpha __P ((int));
  65. extern int    iscntrl __P ((int));
  66. extern int    isdigit __P ((int));
  67. extern int    isgraph __P ((int));
  68. extern int    islower __P ((int));
  69. extern int    isprint __P ((int));
  70. extern int    ispunct __P ((int));
  71. extern int    isspace __P ((int));
  72. extern int    isupper __P ((int));
  73. extern int    isxdigit __P ((int));
  74. extern int    tolower __P ((int));
  75. extern int    toupper __P ((int));
  76.  
  77. #if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE)
  78. extern int    isblank __P ((int));
  79. extern int    isascii __P ((int));
  80. extern int    toascii __P ((int));
  81. extern int    _tolower __P ((int));
  82. extern int    _toupper __P ((int));
  83. #endif
  84. __END_DECLS
  85.  
  86. #define    isdigit(c)    ((_ctype_ + 1)[c] & _N)
  87. #define    islower(c)    ((_ctype_ + 1)[c] & _L)
  88. #define    isspace(c)    ((_ctype_ + 1)[c] & _S)
  89. #define    ispunct(c)    ((_ctype_ + 1)[c] & _P)
  90. #define    isupper(c)    ((_ctype_ + 1)[c] & _U)
  91. #define    isalpha(c)    ((_ctype_ + 1)[c] & (_U|_L))
  92. #define    isxdigit(c)    ((_ctype_ + 1)[c] & (_N|_X))
  93. #define    isalnum(c)    ((_ctype_ + 1)[c] & (_U|_L|_N))
  94. #define    isprint(c)    ((_ctype_ + 1)[c] & (_P|_U|_L|_N|_B))
  95. #define    isgraph(c)    ((_ctype_ + 1)[c] & (_P|_U|_L|_N))
  96. #define    iscntrl(c)    ((_ctype_ + 1)[c] & _C)
  97. #ifdef __GNUC__
  98. #define    toupper(c)    ( { int _c = (c); islower(_c) ? _c - 'a' + 'A' : _c; } )
  99. #define    tolower(c)    ( { int _c = (c); isupper(_c) ? _c - 'A' + 'a' : _c; } )
  100. #endif
  101.  
  102. #if !defined(_ANSI_SOURCE) && !defined (_POSIX_SOURCE)
  103. #if notyet
  104. #define isblank(c)    ((_ctype_ + 1)[c] & _B)
  105. #endif
  106. #define    isascii(c)    ((unsigned)(c) <= 0177)
  107. #define    toascii(c)    ((c) & 0177)
  108. #define isiso(c)    ((unsigned)(c) <= 0377)
  109. #define toiso(c)    ((c) & 0377)
  110. #define _tolower(c)    ((c) - 'A' + 'a')
  111. #define _toupper(c)    ((c) - 'a' + 'A')
  112. #endif
  113.  
  114. #endif /* !_CTYPE_H_ */
  115.